<!--
 * @Author: malgee
 * @Date: 2025-04-27 13:31:26
 * @LastEditors: maling
 * @LastEditTime: 2025-04-27 13:47:30
 * @FilePath: /vue3-ts-cms/src/components/dialog/mg-dialog.vue
 * @Description: 
 * 
-->

<template>
  <div class="mg-dialog">
    <el-dialog v-model="dialogVisible" title="温馨提示" width="500" draggable>
      <slot>确定删除吗?</slot>
      <template #footer>
        <el-button type="primary" @click="close(true)">确定</el-button>
        <el-button @click="close(false)">取消</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref, defineEmits, defineExpose } from 'vue'

const dialogVisible = ref(false)
const emit = defineEmits(['onConfirm'])

const open = () => {
  dialogVisible.value = true
}

const close = (isConfirm: boolean) => {
  dialogVisible.value = false
  emit('onConfirm', isConfirm)
}

// 一定要导出让外面可以访问
defineExpose({ open })

</script>

<style lang="less" scoped>

</style>